﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
using VisualPoint.Controls.Actions;

namespace VisualPoint.Controls.Views
{
    /// <summary>
    /// Interaction logic for AnimationTimeEditor.xaml
    /// </summary>
    public partial class ActionTimeView : UserControl
    {
        public ActionTimeView()
        {
            InitializeComponent();
        }

        public ActionTime ActionTime
        {
            get { return (ActionTime)GetValue(ActionTimeProperty); }
            set { SetValue(ActionTimeProperty, value); }
        }
        public static readonly DependencyProperty ActionTimeProperty =
            DependencyProperty.Register("ActionTime", typeof(ActionTime), typeof(ActionTimeView), new PropertyMetadata(ActionTime.None, ActionTimeChanged));

        private static void ActionTimeChanged(DependencyObject d, DependencyPropertyChangedEventArgs e)
        {
            if (e.NewValue != e.OldValue)
            {
                ((ActionTimeView)d).SetSelectedIndex((ActionTime)e.NewValue);
            }
        }
        private void SetSelectedIndex(ActionTime actionTime)
        {
            lbx.SelectedIndex = (int)actionTime;
        }

        private void ListBox_SelectionChanged(object sender, SelectionChangedEventArgs e)
        {
            ActionTime = (ActionTime)lbx.SelectedIndex;
        }
    }
}
